from django.db import models
from django.contrib.auth.models import User
# Create your models here.
#ORM
#python manage.py inspectdb
class UserInfo(models.Model):
    user = models.OneToOneField(User,on_delete=models.CASCADE)
    mod_data = models.DateTimeField('Last modified',auto_now=True)

    class Meta:
        verbose_name = 'UserInfo'
    def __str__(self):
        return "{}".format(self.user.__str__())


class JobAll(models.Model):
    positionname = models.CharField(db_column='positionName', max_length=72,verbose_name='职位')  # Field name made lowercase.
    company = models.CharField(max_length=72,verbose_name='公司')
    salary = models.CharField(max_length=32,verbose_name='工资')
    location = models.CharField(max_length=72, blank=True, null=True,verbose_name='地址')
    release_time = models.CharField(max_length=32, blank=True, null=True,verbose_name='发布时间')
    work_exp = models.CharField(max_length=32, blank=True, null=True,verbose_name='工作经验')
    edu_background = models.CharField(max_length=32, blank=True, null=True,verbose_name='学历要求')
    company_nature = models.CharField(max_length=32, blank=True, null=True,verbose_name='公司性质')
    company_scale = models.CharField(max_length=32, blank=True, null=True,verbose_name='公司规模')
    url = models.CharField(max_length=104, blank=True, null=True,verbose_name='详情')

    class Meta:
        managed = False
        db_table = 'job_all'


class Job(models.Model):
    companyfullname = models.CharField(db_column='companyFullName', max_length=72,verbose_name='公司')  # Field name made lowercase.
    area = models.CharField(max_length=72,verbose_name='城市')
    location = models.CharField(max_length=72,verbose_name='城市-区')
    positionname = models.CharField(db_column='positionName', max_length=72,verbose_name='职位')  # Field name made lowercase.
    key_word = models.CharField(db_column='Key_word', max_length=72,verbose_name='职业类型')  # Field name made lowercase.
    time = models.CharField(max_length=32, blank=True, null=True,verbose_name='发布时间')
    salary = models.CharField(max_length=32, blank=True, null=True,verbose_name='工资')
    salary_min = models.FloatField(blank=True, null=True,verbose_name='最低工资')
    salary_max = models.FloatField(blank=True, null=True,verbose_name='最高工资')
    url = models.CharField(max_length=104, blank=True, null=True,verbose_name='详情')

    class Meta:
        managed = False
        verbose_name_plural='51job'
        db_table = 'job'

class JobC(models.Model):
    positionname = models.CharField(db_column='positionName', primary_key=True, max_length=255)  # Field name made lowercase.
    key_word = models.CharField(max_length=255)
    company = models.CharField(max_length=80)
    salary = models.CharField(max_length=32)
    salary_min = models.FloatField(blank=True, null=True)
    salary_max = models.FloatField(blank=True, null=True)
    area = models.CharField(max_length=72, blank=True, null=True)
    location = models.CharField(max_length=80)
    release_time = models.CharField(max_length=32, blank=True, null=True)
    work_exp = models.CharField(max_length=32, blank=True, null=True)
    edu_background = models.CharField(max_length=32, blank=True, null=True)
    company_nature = models.CharField(max_length=32, blank=True, null=True)
    company_scale = models.CharField(max_length=32, blank=True, null=True)
    url = models.CharField(max_length=112, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'job_c'
        unique_together = (('positionname', 'company', 'location', 'salary','key_word'),)
